package com.i.picservice.config;

import com.i.piccommon.util.UserContext;
import feign.Logger;
import feign.RequestInterceptor;
import org.springframework.context.annotation.Bean;

/**
 * @author lewis
 * @type class
 * @description
 * @since 2024/10/25
 */
public class DefaultFeignConfig {
    @Bean
    public Logger.Level fullFeignLoggerLevel() {
        return Logger.Level.FULL;
    }
    @Bean
    public RequestInterceptor userInfoRequestInterceptor() {
        return (requestTemplate)-> {
            Long userId = UserContext.getUser();
            if(userId != null) {
                requestTemplate.header("user",userId.toString());
            }
        };
    }
}
